package com.sea.supply.service.impl;

import com.sea.supply.entity.Supplier;
import com.sea.supply.mapper.SupplierMapper;
import com.sea.supply.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SupplierServiceImpl implements SupplierService {

    @Autowired
    private SupplierMapper supplierMapper;

    @Override
    public List<Supplier> findByCnd(Supplier supplier) {
        return supplierMapper.findByCnd(supplier);
    }

    @Override
    public int save(Supplier supplier) {
        return supplierMapper.insert(supplier);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int usave(Supplier supplier) {
        return supplierMapper.update(supplier);
    }

    @Override
    public Supplier findBySupplierName(String supplierName) {
        return supplierMapper.findBySupplierName(supplierName);
    }

    @Override
    public Supplier findById(Integer id) {
        return supplierMapper.findById(id);
    }

    @Override
    public Integer delete(Integer id) {
        return supplierMapper.delete(id);
    }
}
